using NUnit.Framework;
using SDG.UnitTesting.Remoting;
using System.Data.SqlClient;
using System.Data;

namespace SDG.UnitTesting.Example
{
    [SDG]
    [TestFixture]
    public class AttributeBased : SDGContext
    {
        [Test]
        [SDGExecute(@"Database\SampleDatabase_TestTable.sqlgen")]
        public void TestTable_FirstCustomerCorrect()
        {
            SqlConnection sqlConn = new SqlConnection("Server=.;Database=SampleDatabase;;Integrated Security=True");
            SqlCommand sqlCmd = new SqlCommand("SELECT * FROM TestTable", sqlConn);
            SqlDataAdapter sqlDA = new SqlDataAdapter(sqlCmd);

            DataTable dt = new DataTable();
            sqlDA.Fill(dt);

            Assert.AreEqual(1000, dt.Rows.Count);
            Assert.AreEqual("Stefanie476", dt.Rows[0]["Name"]);
            Assert.AreEqual("kezch.fataanj@gtcci.sxuqyb.net", dt.Rows[0]["Email"]);
            Assert.AreEqual("21/02/1969 22:05:24", dt.Rows[0]["DOB"].ToString());
        }

        [Test]
        [SDGExecute(@"Database\SampleDatabase_TestTable2.sqlgen")]
        public void TestTable2_FirstCustomerCorrect()
        {
            SqlConnection sqlConn = new SqlConnection("Server=.;Database=SampleDatabase;;Integrated Security=True");
            SqlCommand sqlCmd = new SqlCommand("SELECT * FROM TestTable2", sqlConn);
            SqlDataAdapter sqlDA = new SqlDataAdapter(sqlCmd);

            DataTable dt = new DataTable();
            sqlDA.Fill(dt);

            Assert.AreEqual(1000, dt.Rows.Count);
            Assert.AreEqual("Nicole2", dt.Rows[0]["Name"]);
            Assert.AreEqual("wyole.xpemygdud@pdoklgl.jyjzsw.net", dt.Rows[0]["Email"]);
            Assert.AreEqual("20/02/1967 04:21:13", dt.Rows[0]["DOB"].ToString());
        }
    }
}
